package com.mybts.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mybts.model.User;
import com.mybts.service.UserService;
import com.mybts.util.Paging;
import com.mybts.util.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wangzhipeng
 * @since 2019-07-27
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;


    @ApiOperation(value = "分页查询用户", notes = "无")
    @RequestMapping(value = "/pageUser", method = RequestMethod.POST)
    public Result<Page<User>> pageUser(Paging page, User user) {

        return Result.success(userService.pageUser(page, user));
    }

    @ApiOperation(value = "增加用户", notes = "无")
    @RequestMapping(value = "/addUser", method = RequestMethod.POST)
    public Result<User> addUser(User user) {

        return Result.success(userService.addUser(user));
    }

    @ApiOperation(value = "修改用户", notes = "无")
    @RequestMapping(value = "/updateUser", method = RequestMethod.POST)
    public Result<User> updateUser(User user) {

        return Result.success(userService.updateUser(user));
    }

    @ApiOperation(value = "删除用户", notes = "无")
    @RequestMapping(value = "/delUser", method = RequestMethod.POST)
    public Result<User> delUser(User user) {

        return Result.success(userService.delUser(user));
    }

}

